package com.mvc4g.example.client.product.actions;

import com.mvc4g.client.ActionInterface;
import com.mvc4g.client.Controller;
import com.mvc4g.client.Event;
import com.mvc4g.example.client.Constants;
import com.mvc4g.example.client.product.ProductBean;
import com.mvc4g.example.client.product.views.DisplayProductView;

public class CreateProductAction implements ActionInterface, Constants {

	@Override
	public void execute(Controller controller, Object form) {
		ProductBean product = (ProductBean) form;
		DisplayProductView displayView = (DisplayProductView) controller
				.getView(DISPLAY_VIEW);
		controller.handleEvent(new Event(CHANGE_PAGE, displayView));
		controller.handleEvent(new Event(SHOW_MESSAGE, "Product Creation Succeeded"));
		displayView.init(product);
	}

}
